using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using FilteredStatistics.View;
using ZoneFiveSoftware.Common.Data.Fitness;
using FilteredStatistics.Common;
using FilteredStatistics.Common.Controller;

namespace FilteredStatistics.Data
{
    class PostProcessPlaceholderFilterCriteria : FilterCriteriaFacade
    {
        public PostProcessPlaceholderFilterCriteria()
        {
        }

#region FilterCriteriaFacade members

        public override Guid ReferenceId
        {
            get { return GUIDs.PostProcessCriteriaGuid; }
        }

        public override String DisplayName
        {
            get { return PluginView.GetLocalizedString("PostProcessText"); }
        }

        public override List<object> NamedZones
        {
            get { return null; }
        }

        public override IActivity Activity
        {
            set { }
        }

        public override bool IsTemplateOnly
        {
            get { return false; }
        }

        public override bool IsMainViewOnly
        {
            get { return false; }
        }

        public override bool IsSerializable
        {
            get { return false; }
        }

        public override void SerializeCriteria(Stream stream)
        {
        }

        public override UInt16 DataVersion
        {
            get { return Constants.CurrentVersion.VersionNumber; }
        }

        public override object DeserializeCriteria(Stream stream, UInt16 version)
        {
            return new PostProcessFilterCriteria(stream, new DataVersion(version));
        }

        public override object OnSelectedInList(object previousSelection)
        {
            if (PostProcessCriteriaSelected != null)
            {
                // Make sure we have maximum 1 registered object since we have a return value
                Debug.Assert(PostProcessCriteriaSelected.GetInvocationList().GetLength(0) == 1);

                IFilterCriteria result;

                PostProcessCriteriaSelected(this, previousSelection as IFilterCriteria, out result);

                return result;
            }

            return previousSelection;
        }

#endregion

#region IPluginSerializable members

        public override void Serialize(Stream stream)
        {
            Debug.Assert(false);
        }

#endregion

#region Deserialization methods

        public void Deserialize_V2(Stream stream, DataVersion version)
        {
            Debug.Assert(false);
        }

#endregion

        public delegate void PostProcessCriteriaSelectedEventHandler(PostProcessPlaceholderFilterCriteria criteria, IFilterCriteria previousCriteria, out IFilterCriteria resultCriteria);
        public event PostProcessCriteriaSelectedEventHandler PostProcessCriteriaSelected;
    }
}
